class App {
	/**骨骼动画管理 */
	public static get DragonBoneManager(): DragonBoneManager {
		return DragonBoneManager.getInstance();
	}
	/**时间管理 */
	public static get  TimerManager(): TimerManager {
		return TimerManager.getInstance();
	}
	/**帧动画 */
	public static get McManager(): McManager {
		return McManager.getInstance();
	}
	/**事件管理 */
	public static get EventManager(): GameEventManager {
		return GameEventManager.getInstance();
	}
	/**事件管理 */
	public static get UiManager(): UiManager {
		return UiManager.getInstance();
	}
	/**请求 */
	public static get  HttpRequestManager(): HttpRequestManager {
		return HttpRequestManager.getInstance();
	}
	/**分帧处理 */
	public static get  DelayOptManager(): DelayOptManager {
		return DelayOptManager.getInstance();
	}
	/**将登录和登录请求结合到一起 */
	public static async login(callback?:Function)
	{
		let login_code = await platform.login();
		let inviter_id = 0;
		if(GameConfig.launchData && GameConfig.launchData.query){
			inviter_id = GameConfig.launchData.query.id;
		}

        var parms = { 
					  code: login_code.code,
					  inviter_id: inviter_id,
					  options:JSON.stringify(GameConfig.launchData)
					}
		App.HttpRequestManager.request(NetConstants.LOGIN, parms, function(res){
			if (res.statusCode == 200 && res.data.code == 0) {
				// 登录成功后的处理
				// 登录成功后保存cookie
				GameConfig.requestHead = res.header['Set-Cookie'];
				let cookieKey = GameConfig.gameName+GameConstants.saveHeaderCookieKey;
				Utils.saveItem2Storage(cookieKey, GameConfig.requestHead);
				// 保存用户信息
				UserData.saveUserInfo(res.data.data);
				
			}else{
				// 登录不成功不处理
			}
            
			// 是否登录成功都执行回调
			if(callback){callback(res);}
		}, egret.HttpMethod.POST,false)
	}
}